import "../../../scss/special/complaints.scss";
import Vue from "vue";
import $ from "jquery";
import com from "../../utils/common"

$(function () {


  let page = {
    _actid:com.getUrlParam("actid") ? com.getUrlParam("actid") :1,
    _app:{},
    _appData:{
      Reason: [
        '欺诈',
        '色情',
        '政治谣言',
        '常识性谣言',
        '诱导分享',
        '恶意营销',
        '隐私信息收集',
        '抄袭公众号文章',
        '其他侵权（冒名、诽谤、抄袭）',
        '违规声明原创',
      ],
      ReasonName: '',
      SelectCheck: false,
      ReasonDesc: '',
    },
    _init:function () {
      let self = this;
      self._loadTemp();
    },
    _loadTemp:function () {
      let self = this;
      self._app = new Vue({
        el:"#app",
        data:self._appData,
        computed: {
          FullWord: function () {
            let res = 200 - this.ReasonDesc.length;
            if (res >= 0) return res;
            else return false;
          },
        },

        methods: {
          GetIndex: function (index) {
            this.ReasonName = this.Reason[index];
            this.SelectCheck = true;
          },
          SubmitComplain:function () {


            let selfApp = this;
            $('.complaint-description').hide();
            $('.weui_icon_msg').attr('class', 'weui_icon_msg weui_icon_warn');
            $('.weui_msg_container').show();
            if (selfApp.SelectCheck && selfApp.ReasonDesc.length > 0) {
              $('.lastone').attr('href', 'javascript:history.back(-1);').html("确定");
              $('.weui_msg_title').html('投诉成功');
              $('.weui_icon_msg').attr('class', 'weui_icon_msg weui_icon_success');
              $('.weui_msg_desc').html('感谢您的参与，我们坚决反对色情、暴力、欺诈等违规信息，我们会认真处理您的投诉，维护绿色、健康的网络环境。');
              com.ajax({
                url:"/normal/complaintSave",
                data:{
                  Actid:self._actid,
                  ReasonName:selfApp.ReasonName,
                  ReasonDesc:selfApp.ReasonDesc,
                },
                ok:function(data){
                  console.log(data)
                }
              })
            } else {
              $('.lastone').click(function () {
                $('.complaint-reason').show();
                $('.complaint-description,.weui_msg_container').hide();
              })
            }

          }
        }
      })
      self._afterTemp()
    },
    _afterTemp:function () {

      function next() {
        $('.complaint-reason').hide();
        $('.complaint-description').show();
      }

      function back() {
        $('.complaint-reason').show();
        $('.complaint-description').hide();
      }
      $("#app").on("click",'.next',function () {
        next();
      });

      $("#app").on("click",'.prev',function () {
        back();
      })


    }
  }
  page._init()
})

